package com.hmall.web;

import com.hmall.client.ItemClient;
import com.hmall.common.dto.PageDTO;
import com.hmall.common.dto.RequestParams;
import com.hmall.common.pojo.Item;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * TODO
 *
 * @Author wangxinyi
 * @Date 2024/11/14 20:08
 */
@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private ItemClient itemClient;

    /**
     * 过滤项聚合功能
     */
    @PostMapping("/filters")
    public Map filters(@RequestBody RequestParams requestParams) {
        //利用fegin技术调用服务item
        return itemClient.searchFilters(requestParams);
    }

    /**
     * 基本搜索功能
     */
    @PostMapping("/list")
    public PageDTO<Item> page(@RequestBody RequestParams requestParams) {
        //利用fegin技术调用服务item
        return itemClient.page(requestParams);
    }
}
